Skip to content

Add Agent.restartIce(): in-place ICE restart on an existing Agent - #310

Closed
bgrozev wants to merge 1 commit into
masterfrom
ice-restart
Closed

Add Agent.restartIce(): in-place ICE restart on an existing Agent#310
bgrozev wants to merge 1 commit into
masterfrom
ice-restart

Conversation

@bgrozev

@bgrozev bgrozev commented Aug 3, 2026

Copy link
Copy Markdown
Member

Summary

Adds Agent.restartIce(): an in-place ICE restart on an already-established Agent, re-running
connectivity checks against new remote credentials (and candidates) without creating a new Agent. Local
credentials, local candidates and sockets are unchanged.

The currently selected pair is kept in use for sending until a new pair is nominated
(make-before-break): the check list and valid list are reset and re-run, but the selected pair is only
replaced once a new nomination is confirmed for the restarting component.

This required relaxing two set-once guards that normally assume nomination happens only once per
component, both gated on a new Component.isIceRestarting flag so ordinary ICE processing is unaffected:

  • CheckList.handleNominationConfirmed() now swaps the selected pair instead of no-oping when the
    component is restarting.
  • ConnectivityCheckClient.processSuccessResponse() now also confirms a nomination while a selected pair
    already exists, if the component is restarting (otherwise the successful check is treated as a
    keepalive and nominationConfirmed() is never called, so the swap never happens and the Agent never
    returns to Completed).

Also un-stops the connectivity check client and cancels a pending or already-fired termination, since a
steady-state Agent has its check client stopped and enters Terminated a few seconds after completion.

This is a leaf dependency for an in-place ICE restart feature spanning jitsi-videobridge and
lib-jitsi-meet (same branch name, ice-restart, in both).

Includes a new test, IceRestartTest, covering the re-arm invariants over a two-agent loopback
connection.

Allows a running Agent to re-run connectivity checks against new
remote credentials (and candidates) without creating a new Agent.
Local credentials, local candidates and sockets are unchanged.

The currently selected pair is kept in use for sending until a new
pair is nominated (make-before-break): the check list and valid list
are reset and re-run, but the selected pair is only replaced once a
new nomination is confirmed for the restarting component.

This requires relaxing two set-once guards that normally assume
nomination happens only once per component:
- CheckList.handleNominationConfirmed() now swaps the selected pair
  instead of no-oping when the component is restarting.
- ConnectivityCheckClient.processSuccessResponse() now also confirms
  a nomination while a selected pair already exists, if the component
  is restarting (otherwise it treats the successful check as a
  keepalive and never calls nominationConfirmed()).

Also un-stops the connectivity check client and cancels a pending or
already-fired termination, since a steady-state Agent has its check
client stopped a few seconds after completion.
@codecov

codecov Bot commented Aug 3, 2026

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 81.48148% with 10 lines in your changes missing coverage. Please review.
✅ Project coverage is 36.78%. Comparing base (6da2b08) to head (add8fff).

Files with missing lines Patch % Lines
src/main/java/org/ice4j/ice/Agent.java 71.42% 5 Missing and 1 partial ⚠️
src/main/java/org/ice4j/ice/CheckList.java 85.71% 1 Missing and 1 partial ⚠️
...in/java/org/ice4j/ice/ConnectivityCheckClient.java 83.33% 0 Missing and 1 partial ⚠️
src/main/java/org/ice4j/ice/IceMediaStream.java 88.88% 0 Missing and 1 partial ⚠️
Additional details and impacted files

Impacted file tree graph

@@             Coverage Diff              @@
##             master     #310      +/-   ##
============================================
+ Coverage     36.44%   36.78%   +0.34%     
- Complexity     1151     1174      +23     
============================================
  Files           166      166              
  Lines         11037    11046       +9     
  Branches       1629     1635       +6     
============================================
+ Hits           4022     4063      +41     
+ Misses         6496     6458      -38     
- Partials        519      525       +6     
Files with missing lines Coverage Δ
src/main/java/org/ice4j/ice/Component.java 40.89% <100.00%> (+2.49%) ⬆️
...in/java/org/ice4j/ice/ConnectivityCheckClient.java 57.70% <83.33%> (-1.39%) ⬇️
src/main/java/org/ice4j/ice/IceMediaStream.java 65.04% <88.88%> (+1.44%) ⬆️
src/main/java/org/ice4j/ice/CheckList.java 60.67% <85.71%> (+1.74%) ⬆️
src/main/java/org/ice4j/ice/Agent.java 57.18% <71.42%> (+3.08%) ⬆️

... and 16 files with indirect coverage changes


Continue to review full report in Codecov by Harness.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 6da2b08...add8fff. Read the comment docs.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@bgrozev bgrozev closed this Aug 5, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant